<!-- HTML header for doxygen 1.8.5-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<title>GenAVB/TSN: Timer API usage</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script src="http://www.freescale.com/files/abstract/misc/COLLATERALTEMPLATE_infocenter.js" type="text/javascript" xml:space="preserve"><!-- --></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="html_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="nxp_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">GenAVB/TSN
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('timer_usage.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Timer API usage </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The timer API provides lightweight and responsive timers which are designed for real-time use cases. Each timer has a dedicated hardware ressource and hence should only be used when precise timing is required. For low resolution timers it's preferable to use OS timers.</p>
<p>First the timer needs to be created using <a class="el" href="group__timer.html#ga065ba556ab3af78941391f4a1ce7758a" title="Allocate/create a new timer.">genavb_timer_create</a> function. This guarantees that the needed hardware ressources are available and reserved. The callback needs to be registered separately using <a class="el" href="group__timer.html#ga582d77a584160b1d7761fb6f5b994047" title="Set the timer callback.">genavb_timer_set_callback</a>. The callback is called in interrupt context when the timer reaches its expiration time and can be called in task context when errors are reported.</p>
<p>Then the timer is started using <a class="el" href="group__timer.html#ga1ea650d3b4107e03397dbb66022e5d22" title="Setup and start a timer created by genavb_timer_create() If the timer is already running it is re-sta...">genavb_timer_start</a> and can be stopped using <a class="el" href="group__timer.html#ga72b8afcf4a94e46387f7ccafb8e33339" title="Stop a running timer The function can be safely called if the timer is already stopped.">genavb_timer_stop</a>. The timer API supports one-shot and periodic operations.</p>
<p>If discontinuities happen for gPTP clocks, the callback returns immediately (with negative count argument). In this case it's needed to restart the timer.</p>
<p>Finally, timer can be fully freed using <a class="el" href="group__timer.html#ga598543f709318ea7453741c393fce297" title="Destroy/free a timer If the timer is still running it will be stopped first.">genavb_timer_destroy</a>.</p>
<h1><a class="anchor" id="pps"></a>
PPS support</h1>
<p>Pulse Per Second feature (PPS) is supported by the timer API by allowing requesting of a timer which has been identified at a lower level to have an available signal output. A PPS timer triggers a pulse signal at each expiration, but otherwise has the same behavior as a regular timer. Currently only one PPS timer can be available. Note that there is no restriction for the timer period contrary to what the PPS term may suggest.</p>
<p>The PPS timer can be requested by using the <a class="el" href="group__timer.html#gga6d99f610a7aec7ff92b2cfb4cabe56ceaafd5ec75682eb8eeb0c61fd376352f26" title="Request or enable PPS signal output.">GENAVB_TIMERF_PPS</a> flag. A succesful call to <a class="el" href="group__timer.html#ga065ba556ab3af78941391f4a1ce7758a" title="Allocate/create a new timer.">genavb_timer_create</a> using this flag guarantee the PPS timer availability and ownership. Then the flag needs to be set again in <a class="el" href="group__timer.html#ga1ea650d3b4107e03397dbb66022e5d22" title="Setup and start a timer created by genavb_timer_create() If the timer is already running it is re-sta...">genavb_timer_start</a> to trigger the output signal. If not set, the timer is started as a regular timer. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.5-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul class="foot">
    <li class="footer"> &copy; 2017-2020 NXP
    </li>
  </ul>
</div>
</body>
</html>
